package com.example.service.impl;

import com.example.dao.MenuDao;
import com.example.entity.Menu;
import com.example.entity.Orders;
import com.example.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author : chenjianhua
 * @date : 17:03 2021/2/23
 */
@Service
public class MenuServiceImpl implements MenuService {

    @Autowired
    private MenuDao menuDao;


    @Override
    public void insert(Menu menu) throws Exception {
        try {
            Menu menu1 = menuDao.findMenuByName(menu);
            if (menu1 != null){
                throw new Exception("菜品已经存在");
            }
            menuDao.insert(menu);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void updatePriceByName(String price,int foodid) throws Exception {
        menuDao.updatePriceByName(price,foodid);
    }

    @Override
    public List<Menu> qryInfo() throws Exception {
        return menuDao.qryMenu();
    }

    @Override
    public Menu qryMenuInfoById(int id) throws Exception {
        return menuDao.qryMenuInfoById(id);
    }

    @Override
    public void updateMenuInfoById(Menu menu) throws Exception {
         menuDao.updateMenuInfoById(menu);
    }

    @Override
    public void deleteMenuInfoById(int foodid) throws Exception {
        menuDao.deleteMenuInfoById(foodid);
    }

    @Override
    public void clickById(Orders orders) throws Exception {
        menuDao.clickById(orders);
    }

    @Override
    public List<Menu> qryMenuByName(String keyword) throws Exception {
        return menuDao.qryMenuByName(keyword);
    }
}
